package it.koutifaris.travianmap.ui;

import junit.framework.Assert;

public class SquaredViewportBoundsTest extends AbstractSquaredViewportBoundsTest {

	public void testGetX() {
		SquaredViewportBounds squaredViewportBounds = new SquaredViewportBounds(originCenteredViewState());
		Assert.assertEquals(0, squaredViewportBounds.getX());
	}

	public void testGetY() {
		SquaredViewportBounds squaredViewportBounds = new SquaredViewportBounds(originCenteredViewState());
		Assert.assertEquals(0, squaredViewportBounds.getY());
	}

	public void testGetXWithTranslation() {
		SquaredViewportBounds squaredViewportBounds = new SquaredViewportBounds(viewState(SQUARE_SIZE + 1, SQUARE_SIZE + 1));
		Assert.assertEquals(1, squaredViewportBounds.getX());
	}

	public void testGetYWithTranslation() {
		SquaredViewportBounds squaredViewportBounds = new SquaredViewportBounds(viewState(SQUARE_SIZE + 1, 2 * SQUARE_SIZE + 1));
		Assert.assertEquals(2, squaredViewportBounds.getY());
	}

	public void testGetWidth() {
		SquaredViewportBounds squaredViewportBounds = new SquaredViewportBounds(viewState(SQUARE_SIZE + 1, SQUARE_SIZE + 1));
		Assert.assertEquals(4, squaredViewportBounds.getWidth(SQUARE_SIZE * 3 + 1));
	}

	public void testGetHeight() {
		SquaredViewportBounds squaredViewportBounds = new SquaredViewportBounds(viewState(SQUARE_SIZE + 1, 2 * SQUARE_SIZE + 1));
		Assert.assertEquals(5, squaredViewportBounds.getHeight(SQUARE_SIZE * 4 + 1));
	}

	public void testGetXNegativeTranslation() {
		SquaredViewportBounds squaredViewportBounds = new SquaredViewportBounds(viewState(-SQUARE_SIZE - 1, -2 * SQUARE_SIZE - 1));
		Assert.assertEquals(-2, squaredViewportBounds.getX());
	}

}
